import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lily
 * Date: 2024-09-20
 * Time: 10:37
 */
public class OneDimensionalPrefixSum {
    public static void main(String[] args) {
        Scanner in =new Scanner(System.in);
        while (in.hasNext()){
            //给定一个长度为n的数组
            int n=in.nextInt();

            //接下来有q次查询
            int q=in.nextInt();
            int[] arr=new int[n+1];
            for (int i = 1; i < arr.length; i++) {
                arr[i]=in.nextInt();
            }
            //dp前缀和数组
            int[] dp=new int[n+1];
            for (int i = 1; i < arr.length; i++) {
                dp[i]=dp[i-1]+arr[i];
            }

            while (q>0){
                int l=in.nextInt();
                int r=in.nextInt();
                System.out.println(dp[r]-dp[l-1]);
                q--;
            }
        }
    }
}
